  function ocell=cr_topcell( auth , spec , subf , outfold , fname , prifname, into , dfname ); 
% function ocell=cr_topcell( auth , spec , subf , outfold , fname , prifname, into , dfname  ); 
% 
% Creates a cell to add at the top of any output file 
% To clearly identify the location and source of output 
% Must provide all inputs but into 
% Make prifname empty if not wish to have it 
% Output ic 4 column cell with rows depending on whether into provided or
% not 
% 
% AJ 6/24/2005 
% ===========================================================
cucd = cd; 
a=strfind(outfold,'\'); 
b=strfind(cucd,'\'); 
temp = find( ismember(a,b) == 0 ); 
if isempty( temp ); 
    outcd = outfold; 
else 
    outcd = outfold( (a(temp(1))+1):end ) ; 
end 
clear temp; 

temp = strdate;

if nargin < 7 | isempty( into ) == 1 
    flag_into = 0; 
ocell = emptycell( 5 , 4  );
else 
    flag_into = 1;     
    ocell = emptycell( 9 , 4 ); 
end 
ocell(1,1:3) = {'auth','spec','subf'};
ocell(2,1:3) = {upper(auth),upper(spec),upper(subf)};
ocell(3,1:3) = {'Folder','Filename','Date'};
ocell(4,1:3) = {upper(outcd),upper(fname),temp};
ocell(5,1:2) = {upper(prifname),'Prior Filename'};
if flag_into == 1
    ocell(6,1:4) = { 'Start sample',num2str( into.start ), 'End sample', num2str( into.finish ) };
    ocell(7,1:4) = { 'Start est',num2str( into.startest), 'Finish Est', num2str( into.finishest ) };
    ocell(8,1:2) = { 'Demean?',num2ans( into.demean ) };
    ocell(9,1:2) = { dfname , 'Data File' }; 
end
